package priv.jesse.mall.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import priv.jesse.mall.entity.ProductComment;

import java.util.List;

/**
  * @className: ProductCommentDao
  * @description: 商品评论dao
  * @author: cy
  * @date: 2019-10-14 
 */
public interface ProductCommentDao extends JpaRepository<ProductComment, Integer> {

    /**
     * 查询商品评论
     * @param id
     * @return
     */

    @Query(value = "select * from product_comment WHERE product_id = :id LIMIT :start,:curPageNO",nativeQuery = true)
    List<ProductComment> findComment(@Param("id") Integer id,@Param("start") Integer start,@Param("curPageNO") Integer curPageNO);

    @Query(value = "select count(1) from product_comment WHERE product_id = :id ",nativeQuery = true)
    int findCountById(@Param("id") Integer id);


}
